package com.anstudio.app.lhasa.core.daos;

import com.anstudio.app.lhasa.core.mappers.SightImgsMapper;
import com.anstudio.app.lhasa.core.modules.SightImgsExample;

import java.util.ArrayList;
import java.util.List;

public class SightImgDao extends BaseDao {

    public List<String> queryImgsBySightId(int sightid) {
        List<String> ret = new ArrayList<>();

        startSession();
        SightImgsMapper mapper = session.getMapper(SightImgsMapper.class);
        SightImgsExample example = new SightImgsExample();
        example.createCriteria().andSightEqualTo(sightid);
        mapper.selectByExampleWithBLOBs(example).stream().forEach(sightImgs -> ret.add(sightImgs.getUrl()));
        endSession();

        return ret;
    }

    @Override
    public Object getObjectById(int id) {
        return getDao(SightImgDao.class, DEFAULT_KEY);
    }

    public static SightImgDao getDao() {
        return getDao(SightImgDao.class, DEFAULT_KEY);
    }
}
